<?php

namespace Transaccion\Controller;

use Transaccion\Controller\GenericController;
use Componentes\Controller\UtilsArrayController;

class HorarioController extends GenericController {

    public function __construct() {
        
    }

    public function get($id) {
        /*
         * Datos del horario COMPLETO
         * Ej: http://localhost/UptaebBackend/public/transaccion/horario/07443224
         * Rsp: {"success":true,"data":[{"salumid":"07443224","smateid":"HSBYC054202",
         * "sseccid":"HS2212","slapsid":"201421","sconmatid":"0","ssemtipins":"0"}],
         * "total":1,"mensaje":null}
         */
        $idEspecialidad = $this->params()->fromRoute('id');
        $output = $this->getHorarioService()->getRegistroCompleto($idEspecialidad);
        return $this->convertirArrayAJson($output);
    }

    /**
     * Return list of resources
     * @return mixed
     */
    public function getList($id = 1, $param1 = 1, $param2 = 1, $param3 = 1) {
        $id = $this->params()->fromRoute('id');
        $param1 = $this->params()->fromRoute('param1');
        $data = null;
        $mensaje = "Defaul";
        $output = null;
        switch ($id) {
            case (1):
                /*
                 * Datos del horario segun Seccion
                 * Ej: http://localhost/UptaebBackend/public/transaccion/horario/1/hs2212
                 * Rsp: {"success":true,
                 * "data":[{"shoraid":"121","smateid":"HSSL2144204","sseccid":"hs2212","slapsid":"201421","saulaidexterno":"H-13","periodo":"3"},
                 * {"shoraid":"122","smateid":"HSSL2144204","sseccid":"hs2212","slapsid":"201421","saulaidexterno":"H-13","periodo":"3"},
                 * ...
                 * {"shoraid":"424","smateid":"HSPR2720224","sseccid":"hs2212","slapsid":"201421","saulaidexterno":"G-21","periodo":"3"}],
                 * "total":15,"mensaje":null}
                 */
                $idEspecialidad = $this->params()->fromRoute('param1');
                $output = $this->getHorarioService()->getRegistros($idEspecialidad);
                break;
            case (2):
                /*
                 * Datos del horario dado la materia, la seccion
                 * Se trae la del lapso de inscripcion
                 * Ej: http://localhost/UptaebBackend/public/transaccion/horario/2/hs2212/HSSL2144204
                 * Rsp: {"success":true,
                 * "data":[{"shoraid":"121","smateid":"HSSL2144204","sseccid":"hs2212","slapsid":"201421","saulaidexterno":"H-13","periodo":"3"},
                 * {"shoraid":"122","smateid":"HSSL2144204","sseccid":"hs2212","slapsid":"201421","saulaidexterno":"H-13","periodo":"3"},
                 * {"shoraid":"123","smateid":"HSSL2144204","sseccid":"hs2212","slapsid":"201421","saulaidexterno":"H-13","periodo":"3"}]
                 * ,"total":3,"mensaje":null}
                 */
                $idLapso = VariablesGlobales::$lapsoDeInscripcion;
                $idSeccion = $this->params()->fromRoute('param1');
                $idMateria = $this->params()->fromRoute('param2');
                $output = $this->getHorarioService()->getSegunIdMateriaIdSeccion($idSeccion, $idMateria, $idLapso);
                break;
            default:
                return $param1;
        }
        return $this->convertirArrayAJson($output);
    }

}
